﻿using System;
using System.Collections.Generic;
using System.Text;
using XBLib.Dal.AdoDal;
using KenLib.BusinessObject;
using DataInfo;
using XBLib.Dal;
using XBLib.BusinessObject;
using System.Data.Common;
using System.Data;

namespace KenLib.Dal
{
    public class frmJ_InterviewResultCheckDao:BaseAdoDao
    {
        public int insert入国Ｇ(入国Ｇ obj, 入国Ｇ詳細 obj1, 企業属性情報 obj2)
        {
            DbParameter param1 = _daoHelper.CreateParameter("@入国Ｇ名", obj.入国Ｇ名, DbType.String);
            DbParameter param2 = _daoHelper.CreateParameter("@団体ID", obj.団体ID, DbType.Int32);
            DbParameter param3 = _daoHelper.CreateParameter("@企業ID", obj1.企業ID, DbType.Int32);
            DbParameter param4 = _daoHelper.CreateParameter("@入国ＧID", obj1.入国ＧID, DbType.Int32);
            DbParameter param5 = _daoHelper.CreateParameter("@送出しID", obj2.送出しID, DbType.Int32);
            DbParameter param6 = _daoHelper.CreateParameter("@廃止区分", obj2.廃止区分, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("insert_入国Ｇ_luclt", CommandType.StoredProcedure, param1, param2, param3, param4, param5, param6);    
            return _daoHelper.Execute(dbcommand);
        }
        public int insert応募状態(応募状態 obj) 
        {
            DbParameter paramID = _daoHelper.CreateParameter("@応募情報ID", obj.応募情報ID, DbType.Int32);
            DbParameter param企業面接欠席 = _daoHelper.CreateParameter("@企業面接欠席", obj.企業面接欠席, DbType.Int32);
            DbParameter param企業面接合格 = _daoHelper.CreateParameter("@企業面接合格", obj.企業面接合格, DbType.Int32);
            DbParameter param企業面接不合格 = _daoHelper.CreateParameter("@企業面接不合格", obj.企業面接不合格, DbType.Int32);
            DbParameter param予備合格 = _daoHelper.CreateParameter("@予備合格", obj.予備合格, DbType.Int32);
            DbParameter param登録ユーザ = _daoHelper.CreateParameter("@登録ユーザ", obj.登録ユーザ, DbType.Int32);
            DbParameter param変更ユーザ = _daoHelper.CreateParameter("@変更ユーザ", obj.変更ユーザ, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("insert_応募状態_luclt", CommandType.StoredProcedure,paramID, param企業面接欠席, param企業面接合格, param企業面接不合格, param予備合格, param登録ユーザ, param変更ユーザ);
            return _daoHelper.Execute(dbcommand);

        }
        public int insert基本情報(基本情報 obj)
        {
            DbParameter param団体ID = _daoHelper.CreateParameter("@団体ID", obj.団体ID, DbType.Int32);
            DbParameter param企業ＩＤ = _daoHelper.CreateParameter("@企業ＩＤ", obj.企業ＩＤ, DbType.Int32);
            DbParameter param送出しID = _daoHelper.CreateParameter("@送出しID", obj.送出しID, DbType.Int32);
            DbParameter paramIDSelect = _daoHelper.CreateParameter("@IDSelect", obj.IDselect, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("insert_基本情報_luclt", CommandType.StoredProcedure, param団体ID, param企業ＩＤ, param送出しID, paramIDSelect);
            return _daoHelper.Execute(dbcommand);
        }
        //public int delete_面接詳細情報_luclt(面接詳細情報 obj)
        //{
        //    DbParameter param6 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
        //    DbParameter param1 = _daoHelper.CreateParameter("@団体ID", obj.団体ID, DbType.Int32);
        //    DbParameter param2 = _daoHelper.CreateParameter("@企業ID", obj.企業ID, DbType.Int32);
        //    DbParameter param5 = _daoHelper.CreateParameter("@応募情報ID", obj.応募情報ID, DbType.Int32);
        //    DbCommand dbcommand = _daoHelper.CreateCommand("delete_面接詳細情報_luclt", CommandType.StoredProcedure, param6, param1, param2, param5);
        //    return _daoHelper.Execute(dbcommand);
        //}
        public int update_企業属性情報_luclt(企業属性情報 obj)
        {
            DbParameter param団体ID = _daoHelper.CreateParameter("@団体ID", obj.団体ID, DbType.Int32);
            DbParameter param企業ＩＤ = _daoHelper.CreateParameter("@企業ID", obj.企業ID, DbType.Int32);
            DbParameter param送出しID = _daoHelper.CreateParameter("@送出しID", obj.送出しID, DbType.Int32);
            DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("update_企業属性情報_luclt", CommandType.StoredProcedure, param団体ID, param企業ＩＤ, param送出しID, param廃止区分);
            return _daoHelper.Execute(dbcommand);
        }
        public int update_面接情報_luclt(面接情報 obj)
        {
            DbParameter param1 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
            DbParameter param2 = _daoHelper.CreateParameter("@終了区分", obj.終了区分, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("update_面接情報_luclt", CommandType.StoredProcedure, param1, param2);
            return _daoHelper.Execute(dbcommand);
        }
        public int insertAll(入国Ｇ obj, 入国Ｇ詳細 obj1, 企業属性情報 obj2,  List<応募状態> obj3, List<基本情報> obj4, List<面接情報> obj5)
        {
            DbConnection conn = _daoHelper.GetConnection();
            conn.Open();
            DbTransaction trs = conn.BeginTransaction();
            try
            {
                insert入国Ｇ(obj, obj1, obj2);
                for (int i = 0; i < obj3.Count; i++)
                {
                    insert応募状態(obj3[i]);
                }
                for (int i = 0; i < obj4.Count; i++)
                {
                    insert基本情報(obj4[i]);
                } for (int i = 0; i < obj5.Count; i++)
                {
                    //delete_面接詳細情報_luclt(obj4[i]);
                    update_面接情報_luclt(obj5[i]);
                }
                //update_企業属性情報_luclt(obj5);
                trs.Commit();
            }
            catch (Exception ex)
            {
                trs.Rollback();
            }
            conn.Close();
            return 1;
        }


        #region Vh
        
        //Date: 19/01/2010 Friday
        public bool frmJ_TraineeInterviewList_CheckExistsID(string Id)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_CheckExistsID_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@ID", Id);
            command.Parameters.Add(para1);

            DataTable dt = _daoHelper.Query(command);
            if (dt.Rows.Count > 0)
                return true;//exists key in table 応募状態
            return false;
        }

        public int frmJ_TraineeInterviewList_Insert_Case5(int 応募情報ID, DateTime 変更年月日, int 変更ユーザ)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Insert_Case5_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }


        public int frmJ_TraineeInterviewList_Update_Case6(int 応募情報ID, DateTime 変更年月日, int 変更ユーザ)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Update_Case6_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }

        public int frmJ_TraineeInterviewList_Insert_Case7(int 応募情報ID, DateTime 変更年月日, int 変更ユーザ)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Insert_Case7_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }

        public int frmJ_TraineeInterviewList_Insert_Case1(int 応募情報ID, DateTime 登録年月日, int 登録ユーザ, DateTime 変更年月日, int 変更ユーザ, string 来社せず理由内容)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Insert_Case1_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para12 = _daoHelper.CreateParameter("@登録年月日", 登録年月日);
            DbParameter para13 = _daoHelper.CreateParameter("@登録ユーザ", 登録ユーザ);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            DbParameter para4 = _daoHelper.CreateParameter("@来社せず理由内容", 来社せず理由内容);

            command.Parameters.Add(para1);
            command.Parameters.Add(para12);
            command.Parameters.Add(para13);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            command.Parameters.Add(para4);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }

        public int frmJ_TraineeInterviewList_Update_Case2(int 応募情報ID, DateTime 変更年月日, int 変更ユーザ, string 来社せず理由内容)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Update_Case2_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            DbParameter para4 = _daoHelper.CreateParameter("@来社せず理由内容", 来社せず理由内容);

            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            command.Parameters.Add(para4);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }

        public int frmJ_TraineeInterviewList_Insert_Case3(int 応募情報ID, DateTime 登録年月日, int 登録ユーザ, DateTime 変更年月日, int 変更ユーザ)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Insert_Case3_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@登録年月日", 登録年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@登録ユーザ", 登録ユーザ);
            DbParameter para4 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para5 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);

            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            command.Parameters.Add(para4);
            command.Parameters.Add(para5);
            
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }


        public int frmJ_TraineeInterviewList_Update_Case4(int 応募情報ID, DateTime 変更年月日, int 変更ユーザ)
        {
            DbCommand command = _daoHelper.CreateCommand("sp_frmJ_TraineeInterviewList_Update_Case4_Dong", CommandType.StoredProcedure);
            DbParameter para1 = _daoHelper.CreateParameter("@応募情報ID", 応募情報ID);
            DbParameter para2 = _daoHelper.CreateParameter("@変更年月日", 変更年月日);
            DbParameter para3 = _daoHelper.CreateParameter("@変更ユーザ", 変更ユーザ);
            command.Parameters.Add(para1);
            command.Parameters.Add(para2);
            command.Parameters.Add(para3);
            int i = 0;
            i = _daoHelper.Execute(command);
            return i;
        }
        #endregion
    }
}
